<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改医废处置机构、医疗机构关系')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-medicalHospitalRelationship-edit" th:object="${yfMedicalWasteAndHospitalRelationship}">
            <input name="id" th:field="*{id}" type="hidden">
            <!--      医废处置单位id      -->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">医废处理单位：</label>
                <div class="col-sm-8">
                    <select name="medicalWasteId" class="form-control" th:with="v=${@dep.getYFMedicalWasteList()}" required>
                        <option value="" >------请选择医疗废物处置单位------</option>
                        <option th:each="l : ${v}" th:text="${l.name}" th:value="${l.id}" th:field="*{medicalWasteId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">医疗机构单位：</label>
                <div class="col-sm-8">
                    <select name="hospitalId" id="hospitalId" class="form-control"  th:with="v=${deptList}" required>
                        <option value="" >------请选择医疗机构------</option>
                        <option th:each="l:${v}" th:text="${l.deptName}" th:value="${l.deptId}" th:field="*{hospitalId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">开始签约时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="startSigningDate" id="startSigningDate" th:value="${#dates.format(yfMedicalWasteAndHospitalRelationship.startSigningDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">结束签约时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="endSigngingDate" th:value="${#dates.format(yfMedicalWasteAndHospitalRelationship.endSigngingDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group" shiro:hasAnyRoles="admin">
                <label class="col-sm-3 control-label">等级类型：</label>
                <div class="col-sm-8">
                    <select name="hospType" class="form-control m-b" th:with="type=${@dict.getType('yf_hospital_grade')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{hospType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group"  shiro:hasAnyRoles="admin">
                <label class="col-sm-3 control-label">删除状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('del_flag')}">
                        <input type="radio" th:id="${'delFlag_' + dict.dictCode}" name="delFlag" th:value="${dict.dictValue}" th:field="*{delFlag}">
                        <label th:for="${'delFlag_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js"/>
    <script type="text/javascript">
        var prefix = ctx + "yf/medicalHospitalRelationship";
        $("#form-medicalHospitalRelationship-edit").validate({
            focusCleanup: true,
            rules:{
                "startSigningDate":{
                    required: true
                },
                "endSigngingDate": {
                    required: true,
                    compareDate: "#startSigningDate"
                }
            },messages:{
                "startSigningDate":{
                    required: "开始时间不能为空"
                },
                "endSigngingDate":{
                    required: "结束时间不能为空",
                    compareDate: "结束日期必须大于开始日期!"
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-medicalHospitalRelationship-edit').serialize());
            }
        }

        jQuery.validator.methods.compareDate = function(value, element, param) {
            //var startDate = jQuery(param).val() + ":00";补全yyyy-MM-dd HH:mm:ss格式
            //value = value + ":00";

            var startDate = jQuery(param).val();
            var date1 = new Date(Date.parse(startDate.replace("-", "/")));
            var date2 = new Date(Date.parse(value.replace("-", "/")));
            return date1 < date2;
        };


        $("input[name='startSigningDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endSigngingDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>